<template>
  <div class="talk-process-set">
    <div class="talk-process-set__header">
      <div class="talk-process-set__header-content">
        <div class="process-info">
          <span class="process-title__name">流程名称：{{ info.name }}</span>
          <span class="process-title__id">会话ID：{{ info.info }}</span>
          <span class="process-title__remark">备注：{{ info.remark }}</span>
        </div>
        <FlowActions :info />
      </div>
    </div>
    <div class="talk-process-set__body flex-1" @click="showChooseNodes = true">
      <ChooseNodes />
      <FlowBody :info />
      <ScriptInfo />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ProcessApi, ProcessVO } from '@/api/system/process'
import { useFlowStore } from '@/store/modules/flow'
import * as _ from 'lodash-es'

defineOptions({ name: 'ProcessSet' })

const showChooseNodes = ref(false)
const Default_Info: ProcessVO = {
  id: 0,
  name: '',
  info: '',
  record: '',
  remark: ''
}
const info = reactive<ProcessVO>(Default_Info)

onMounted(async () => {
  const route = useRoute()
  _.assign(info, await ProcessApi.getProcess(Number(route.query.id)))
})

onUnmounted(() => {
  const store = useFlowStore()
  store.$reset()
})
</script>

<style lang="less" scoped>
.talk-process-set {
  min-height: calc(
    100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) - 20px
  );
  display: flex;
  flex-direction: column;
  row-gap: 12px;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;

  &__header,
  &__body {
    padding: 16px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
  }

  &__body {
    display: flex;
    position: relative;
  }
}

.talk-process-set__header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.process-info {
  display: flex;
  gap: 24px;
  align-items: center;

  &__name {
    font-weight: 600;
    color: #1890ff;
  }

  &__id {
    color: #666;
  }

  &__remark {
    color: #999;
  }
}

.process-info span {
  display: flex;
  align-items: center;
  font-size: 14px;
  color: #333;
}

.process-info span::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  background: #1890ff;
  border-radius: 50%;
}
</style>
